<?php $this->load->view('header'); ?>
<?php
if ($msg = $this->session->flashdata('flash_message')) {
   //showMessage($msg['type'], $msg['msg']);
?>
    <script type="text/javascript">
        $.notify(
            "<?php echo $msg['msg']?>", 
            { 
               position:"top center",
                showAnimation: 'slideDown',
                autoHideDelay: 2000,
                className: 'success',
                hideAnimation: 'slideUp',
                autoHide: true,
                autoHideDelay: 3000,
                
            }
        );
    </script>
<?php
    
}
?>
<div id="search-project">
	<?php echo $this->load->view('sideBlocks/searchBlock') ?>
</div>
  <div class="wrap-content wrap-project">
        <div class="container">
            <div class="detail-profile">
                <div class="border col-md-1 col-xs-1"></div>
                <div class="container">
                    <div class="row title-project">
                        <h2><?php echo $this->lang->line("Projects_bidding_on") ?></h2>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="wrap-content wrap-public-message">
    </div>
    <div class="wrap-content wrap-project">
    <div class="container">
        <div class="">
            <div class="list-project col-lg-12">
                <div class="table-projects row">
                             <table id="" cellspacing="1" cellpadding="2" class="col-lg-12 table col-md-12 col-sm-12 col-xs-12 no-padding" >
                                <thead>
                                <tr class="x8-16-b">
                                  <td class="dt"><?php echo $this->lang->line('Project Name');?></td>
                                  <td class="dt"><?php echo $this->lang->line('Num bid');?></td>
                                  <td class="dt"><?php echo $this->lang->line('Bids');?></td>
								  <td class="dt"><?php echo $this->lang->line('Status');?></td>
								  <td class="dt"><?php echo $this->lang->line('Deadline');?></td>
								  <td class="dt"><?php echo $this->lang->line('Bid time');?></td>
<!--								  <td class="dt">--><?php //echo $this->lang->line('Options');?><!--</td>-->
                                </tr>
                                </thead>
								<?php
						  	
						  	if(isset($biddingProjects) and $biddingProjects->num_rows()>0)
							{
								foreach($biddingProjects->result() as $latestProject)
								{
									if($latestProject->project_award_date > 0){
										$deadline = $latestProject->project_award_date + ($latestProject->bid_days * 86400);
									} 
							?>
                                <tr class="x8-15">
                                  <td class="xanh-16-b"><a style="font-size:18px;" href="<?php echo site_url('project/view/'.$latestProject->id); ?>"><?php echo $latestProject->project_name; ?></a></td>
                                  <td><?php echo getNumBid($latestProject->id);?></td>
                                  <td><?php echo "$ ".$latestProject->bid_amount; ?></td>
								  <td><?php echo getProjectStatus($latestProject->project_status);?></td>
								  <td><?php echo (isset($deadline))?get_date($deadline):"";?></td>
								  <td><?php echo get_date($latestProject->bid_time);?></td>
<!--                                  <td>-->
<!--								  --><?php //if($latestProject->programmer_id == $programmer_id){  ?>
<!--								  <a href="--><?php //echo site_url('project/acceptProject/'.$latestProject->id."/".$latestProject->checkstamp);?><!--" onclick="return modal(this, 'Confirm', 'Do you want to accept the project?', 'confirm')">--><?php //echo $this->lang->line('Accept');?><!--</a>/-->
<!--								  <a href="--><?php //echo site_url('project/denyProject/'.$latestProject->id)."/".$latestProject->checkstamp;?><!--" onclick="return confirm('Do you want to deny the project?');">--><?php //echo $this->lang->line('Deny');?><!--</a>-->
<!--								  --><?php //} else {?>
<!--								  <a href="--><?php //echo site_url('programmer/retractBid/'.$latestProject->bidid);?><!--" onclick="return modal(this, 'Confirm', 'Are you sure you want to retract your bid?', 'confirm')">--><?php //echo $this->lang->line('Retract your bid');?><!--</a>-->
<!--								  --><?php //} ?>
<!--								  </td>-->
                                </tr>
                              <?php		
								}//For Each End - Latest Project Traversal															
							}//If - End Check For Latest Projects
							else{
							
							echo "<tr><td colspan='8'>".$this->lang->line('No Projects')."</td></tr>";
							}
						  ?>
                              </tbody></table>
							  <?php if(isset($pagination)) echo $pagination;?>
					</div>
				</div>
			</div>
		</div>
	<div class="wrap-content wrap-project">
        <div class="container">
            <div class="detail-profile">
                <div class="border col-md-1 col-xs-1"></div>
                <div class="container">
                    <div class="row title-project">
                        <h2><?php echo $this->lang->line("Projects_won") ?></h2>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="wrap-content wrap-public-message">
    </div>
    <div class="wrap-content wrap-project">
    <div class="container">
        <div class="">
            <div class="list-project col-lg-12">
                <div class="table-projects row">							  
                             <table cellspacing="1" cellpadding="2" class="col-lg-12 table col-md-12 col-sm-12 col-xs-12 no-padding">
                                <thead>
                                <tr class="x8-16-b">
                                  <td class="dt"><?php echo $this->lang->line('Project Name');?></td>
								  <td class="dt"><?php echo $this->lang->line('Bids');?></td>
                                  <td class="dt"><?php echo $this->lang->line('Avg Bid');?></td>
								  <td class="dt"><?php echo $this->lang->line('Status');?></td>
								  <td class="dt"><?php echo $this->lang->line('Posted');?> </td> 
								  <td class="dt"><?php echo $this->lang->line('Options');?></td>
                                </tr>
                                </thead>
								 <?php
						  	
							  	if(isset($wonBids) and $wonBids->num_rows()>0)
								{
									foreach($wonBids->result() as $wonBid)
									{
										$reviewDetails = getReviewStatusProgrammer($wonBid->id,$wonBid->programmer_id);
										$reviewDetails = $reviewDetails->row();
										//if(!is_object($reviewDetails))
									    //{	
								?>
                               <tr class="x8-15">
                                  <td class="xanh-16-b"><a href="<?php echo site_url('project/view/'.$wonBid->id); ?>"><?php echo $wonBid->project_name; ?></a></td>
								  <td><?php echo "$ ".$wonBid->bid_amount;?></td>
                                  <td><?php echo getBidsInfo($wonBid->id); ?></td>
								  <td><?php echo getProjectStatus($wonBid->project_status);?></td>
								  <td><?php echo get_date($wonBid->created);?></td> 
								  <td><a class="review-buyer" data-href="<?php echo site_url('programmer/reviewBuyer/'.$wonBid->id);?>" data-toggle="modal"><?php echo $this->lang->line('Review');?></a></td>
                                </tr>
                                <?php		
								 }					
								}//For Each End - Latest Project Traversal															
							//}//If - End Check For Latest Projects
							else{
							
							echo "<tr><td colspan='8'>".$this->lang->line('No Projects')."</td></tr>";
							}
						  ?>
                      </tbody>
                 </table>			
              </div>
            </div>
          </div>
        </div>
      </div>
      <!--END OF POST PROJECT-->
    </div>

<!--END OF MAIN-->
<?php $this->load->view('footer'); ?>